package cn.iocoder.yudao.module.fengdong.smartelderly.dal.mysql.dynamic;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.fengdong.smartelderly.dal.dataobject.dynamic.DynamicDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin.dynamic.vo.*;

/**
 * 老人动态管理 Mapper
 *
 * @author 沣东养老院管理员
 */
@Mapper
public interface DynamicMapper extends BaseMapperX<DynamicDO> {

    default PageResult<DynamicDO> selectPage(DynamicPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DynamicDO>()
                .eqIfPresent(DynamicDO::getIdentityCard, reqVO.getIdentityCard())
                .eqIfPresent(DynamicDO::getOthers, reqVO.getOthers())
                .betweenIfPresent(DynamicDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DynamicDO::getType, reqVO.getType())
                .orderByDesc(DynamicDO::getId));
    }

    default List<DynamicDO> selectList(DynamicExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DynamicDO>()
                .eqIfPresent(DynamicDO::getIdentityCard, reqVO.getIdentityCard())
                .eqIfPresent(DynamicDO::getOthers, reqVO.getOthers())
                .betweenIfPresent(DynamicDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DynamicDO::getType, reqVO.getType())
                .orderByDesc(DynamicDO::getId));
    }

}
